<template>
  <div class="aside-wrapper">
    <div class="header" @click="tab">
      <span class="header-calc-text" :class="{ active: isActive }" order="1"
        >历史记录</span
      >
      <span class="header-calc-text" :class="{ active: !isActive }" order="2"
        >记忆</span
      >
    </div>
    <div class="body">
      <transition name="slide-fade">
        <div v-show="isActive">
          <div v-for="item in histories" :key="item.id" class="hisItem">
            <span class="process" v-text="`${item.process}=`"></span>
            <span class="result">{{item.result}}</span>
          </div>
        </div>
      </transition>
      <transition name="slide-fade">
        <div v-show="!isActive">记忆</div>
      </transition>
    </div>
    <div class="footer">
      <i class="el-icon-delete"></i>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Header',
  props: {},
  data() {
    return {
      isActive: true,
      histories: [
        { id: 1, process: '1 + 2', result: '3'},
        { id: 2, process: '1 × 2', result: '2'}
      ]
    }
  },
  computed: {},
  methods: {
    tab(e) {
      this.isActive = e.target.attributes.order.value === '1'
    },
  },
}
</script>

<style scoped lang="scss">
@import '@/assets/css/theme.scss';
.aside-wrapper {
  position: relative;
  width: 300px;
}
.header {
  margin-bottom: 30px;
  .header-calc-text {
    display: inline-block;
    text-align: center;
    font-weight: 700;
    font-size: $fz-18;
    height: 30px;
    line-height: 30px;
    margin-right: 10px;
    border-bottom-width: 4px;
    border-bottom-style: solid;
    border-bottom-color: transparent;
  }
  .active {
    border-bottom-color: #000;
  }
}
.body {
  position: relative;
}
.hisItem {
  display: flex;
  flex-direction: column;
  padding: 10px;
  &>span {
    text-align: right;
  }
  &>.result {
    margin-top: 10px;
    font-size: $fz-18;
    font-weight: 700;
  }
}
.footer {
  position: absolute;
  bottom: 0;
  right: 0;
}
.slide-fade-enter-active {
  transition: all .3s ease;
}
.slide-fade-leave-active {
  transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
  transform: translateX(10px);
  opacity: 0;
}
</style>
